<?php
class Core_Common_Controllers_Actions_Helpers_RegistrationValidator extends Zend_Controller_Action_Helper_Abstract {
	public $view;
	
	public function setView(Zend_View_Interface $view) {
		$this->view = $view;
	}
	
	public function isEmail($value) {
		if(preg_match("`^[[:alnum:]]([-_.]?[[:alnum:]_?])*@[[:alnum:]]([-.]?[[:alnum:]])+\.([a-z]{2,6})$`", $value)) {
			return true;
		}
		return false;
	}
	public function isSalutation($value) {
		if(preg_match("`^(M|Mme|Mlle)$`", $value)>0) {
			return true;
		}
		return false;
	}
	public function isName($value) {
		if(preg_match("`^([[:alpha:]])+(([-]|\s)([[:alpha:]])+)*$`", $value)) {
			return true;
		}
		return false;
	}
	public function isZipcode($value) {
		if(preg_match("`^[[:digit:]][1-9]([[:digit:]]){3,3}$`", $value)) {
			return true;
		}
		return false;
	}
	public function isCity($value) {
		if(preg_match("`^([[:alpha:]])+(([-]|\s)([[:alpha:]])+)*$`", $value)) {
			return true;
		}
		return false;
	}
	public function isPassword($value) {
		if(preg_match("`^([a-zA-Z0-9\-_$*!]){5,18}$`", $value)) {
			return true;
		}
		return false;
	}
	
	public function isPayment($value) {
		if(Core_Business_Payment::getById($value) instanceof Core_Business_Payment) {
			return true;
		}
		return false;
	}
	public function isExpertises($value) {
		$values = is_array($value)==true ? $value : array($value);
		$validity = true;
		if($values!=null && $value!=null) {
			foreach ($values as $item) {
				if(!Core_Business_Expertises::getById($item) instanceof Core_Business_Expertises)
					$validity = false;
					
				if($validity==false)
					break;
			}
		}
		else 
			$validity = false;
			
		return $validity;
	}
}